﻿
using System ;
using System.Windows.Forms ;

using MskEdit.Msk.Model ;


namespace MskEdit.Msk.Frontend {

    public static class MskFieldGeometerFactory
    {
        public static MskFieldGeometer createFrom( Form form ) {
        
            MskFieldUserControl mskFieldUserControlPrototype = new MskFieldUserControl() ;
            
            Label captionLabelPrototype  = new Label() ;
            Label valueLabelPrototype    = new Label() ;
            
            captionLabelPrototype.AutoSize = true ;
            valueLabelPrototype.AutoSize = true ;
            
            mskFieldUserControlPrototype.getCaptionTextBoxApperance().applyOn( captionLabelPrototype ) ;
            mskFieldUserControlPrototype.getValueTextBoxApperance().applyOn( valueLabelPrototype ) ;
        
            MskCellGeometry captionCellGeometry = MskCellGeometryFactory.createFrom( form, captionLabelPrototype ) ;
            MskCellGeometry valueCellGeometry = MskCellGeometryFactory.createFrom( form, valueLabelPrototype ) ;

            int fieldMargin = Math.Max( mskFieldUserControlPrototype.Margin.All, 0 ) ;
            
            MskFieldGeometer fieldGeometer = new MskFieldGeometer( captionCellGeometry, valueCellGeometry, fieldMargin ) ;
            
            return fieldGeometer ;
        }
    }
}
